package com.beney.codec;

import com.alibaba.fastjson.JSON;
import com.beney.message.Message;

public class MessagePacket {
    /**
     * 类型
     */
    private String type;

    /**
     * JSON 格式的消息内容
     */
    private String message;

    public MessagePacket() {
    }

    public MessagePacket(String type, String message) {
        this.type = type;
        this.message = message;
    }

    public MessagePacket(String type, Message message) {
        this.type = type;
        this.message = JSON.toJSONString(message);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "Protocol{" +
                "type='" + type + "'" +
                ", message='" + message + "'" +
                "}";
    }
}
